package com.wy.materialdesign.customBehavior;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wy.materialdesign.R;
import com.wy.materialdesign.coordinatorLayout.Fruit;
import com.wy.materialdesign.coordinatorLayout.MyAdapter;

import java.util.ArrayList;
import java.util.List;

public class CustomBehaviorActivity extends AppCompatActivity {


    private List<Fruit> fruitList = new ArrayList<>();
    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_behavior);

        recyclerView = findViewById(R.id.recycler_view);

        initData();
        MyAdapter myAdapter = new MyAdapter(this, fruitList);
        //网格
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
        recyclerView.setAdapter(myAdapter);
    }

    private void initData() {
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "香蕉"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "苹果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "橘子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "火龙果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "西瓜"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "桃子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "香蕉"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "苹果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "橘子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "火龙果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "西瓜"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "桃子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "香蕉"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "苹果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "橘子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "火龙果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "西瓜"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "桃子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "香蕉"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "苹果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "橘子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "火龙果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "西瓜"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "桃子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "香蕉"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "苹果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "橘子"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "火龙果"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "西瓜"));
        fruitList.add(new Fruit(R.mipmap.ic_launcher, "桃子"));
    }

}